{% load widget_tweaks %}

<div class="row bg-info-lighten border-top border-bottom">
    <div class="col-6 checkbox pt-1 pb-1">
        <h5><i class="mdi mdi-card-plus font-18" style="color: #7aa6da"></i>&nbsp;기본 설정</h5>
    </div>
    <div class="col-6 m-auto text-right checkbox">
        <label class="m-auto">
            <input type="checkbox"
                   data-toggle="collapse"
                   data-target="#collapseForm"
                   aria-expanded="false"
                   aria-controls="collapseForm"
                   {% if not bill_issue %}checked{% endif %}> 고지서 관련 세부설정
        </label>
    </div>
</div>

<form method="post" name="bill_set" class="col-12 p-0 needs-validation" novalidate>
    {% csrf_token %}

    <div class="col-12 form-row mt-3 p-0">
        <div class="col-12 form-row">
            <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.published_date.id_for_label }}">
                {{ form.published_date.label }}
            </label>
            <div class="col-sm-8 col-md-4 col-lg-2">
                {{ form.published_date|add_class:"form-control mb-1 text-primary"|attr:"placeholder:발행일자"|attr:"data-provide=datepicker data-date-format=yyyy-mm-dd data-date-autoclose=true data-toggle=input-mask data-mask-format=0000-00-00"|attr:"style:background: lightyellow" }}
                {{ form.published_date.errors }}
            </div>
            <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.now_payment_order.id_for_label }}">
                {{ form.now_payment_order.label }}
            </label>
            <div class="col-sm-8 col-md-4 col-lg-2">
                {{ form.now_payment_order|add_class:"form-control mb-1 text-primary"|attr:"style:background: lightyellow" }}
                {{ form.published_date.errors }}
            </div>

            <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.now_payment_order.id_for_label }}">
                {{ form.now_due_date.label }}
            </label>
            <div class="col-sm-8 col-md-4 col-lg-2">
                {{ form.now_due_date|add_class:"form-control mb-1 text-primary"|attr:"placeholder:당회 납부기한"|attr:"data-provide=datepicker data-date-format=yyyy-mm-dd data-date-autoclose=true data-toggle=input-mask data-mask-format=0000-00-00"|attr:"style:background: lightyellow" }}
                {{ form.now_due_date.errors }}
            </div>
            <div class="d-none d-md-block col-md-6 col-lg-3"></div>
        </div>

        <div class="collapse col-12 form-row pr-0 mr-0 {% if not bill_issue %}show{% endif %}" id="collapseForm">
            <div class="col-12 form-row">
                <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.host_name.id_for_label }}">
                    {{ form.host_name.label }}
                </label>
                <div class="col-sm-8 col-md-4 col-lg-2">
                    {{ form.host_name|add_class:"form-control mb-1"|attr:"placeholder:시행자명" }}
                    {{ form.host_name.errors }}
                </div>
                <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.host_tel.id_for_label }}">
                    {{ form.host_tel.label }}
                </label>
                <div class="col-sm-8 col-md-4 col-lg-2">
                    {{ form.host_tel|add_class:"form-control mb-1"|attr:"placeholder:시행자 전화" }}
                    {{ form.host_tel.errors }}
                </div>
                <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.agency.id_for_label }}">
                    {{ form.agency.label }}
                </label>
                <div class="col-sm-8 col-md-4 col-lg-2">
                    {{ form.agency|add_class:"form-control mb-1"|attr:"placeholder:대행사명" }}
                    {{ form.agency.errors }}
                </div>
                <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.agency_tel.id_for_label }}">
                    {{ form.agency_tel.label }}
                </label>
                <div class="col-sm-8 col-md-4 col-lg-2">
                    {{ form.agency_tel|add_class:"form-control mb-1"|attr:"placeholder:대행사 전화" }}
                    {{ form.agency_tel.errors }}
                </div>
            </div>

            <div class="col-12 form-row">
                <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.bank_account1.id_for_label }}">
                    {{ form.bank_account1.label }}
                </label>
                <div class="col-sm-8 col-md-4 col-lg-3">
                    {{ form.bank_account1|add_class:"form-control mb-1"|attr:"placeholder:수납은행[1]" }}
                    {{ form.bank_account1.errors }}
                </div>
                <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.bank_number1.id_for_label }}">
                    {{ form.bank_number1.label }}
                </label>
                <div class="col-sm-8 col-md-4 col-lg-3">
                    {{ form.bank_number1|add_class:"form-control mb-1"|attr:"placeholder:계좌번호[1]" }}
                    {{ form.bank_number1.errors }}
                </div>
                <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.bank_host1.id_for_label }}">
                    {{ form.bank_host1.label }}
                </label>
                <div class="col-sm-8 col-md-4 col-lg-3">
                    {{ form.bank_host1|add_class:"form-control mb-1"|attr:"placeholder:예금주[1]" }}
                    {{ form.bank_host1.errors }}
                </div>
                <div class="d-none d-md-block col-md-6 d-lg-none"></div>
            </div>

            <div class="col-12 form-row">
                <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.bank_account2.id_for_label }}">
                    {{ form.bank_account2.label }}
                </label>
                <div class="col-sm-8 col-md-4 col-lg-3">
                    {{ form.bank_account2|add_class:"form-control mb-1"|attr:"placeholder:수납은행[2]" }}
                    {{ form.bank_account2.errors }}
                </div>
                <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.bank_number2.id_for_label }}">
                    {{ form.bank_number2.label }}
                </label>
                <div class="col-sm-8 col-md-4 col-lg-3">
                    {{ form.bank_number2|add_class:"form-control mb-1"|attr:"placeholder:계좌번호[2]" }}
                    {{ form.bank_number2.errors }}
                </div>
                <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.bank_host2.id_for_label }}">
                    {{ form.bank_host2.label }}
                </label>
                <div class="col-sm-8 col-md-4 col-lg-3">
                    {{ form.bank_host2|add_class:"form-control mb-1"|attr:"placeholder:예금주[2]" }}
                    {{ form.bank_host2.errors }}
                </div>
                <div class="d-none d-md-block col-md-6 d-lg-none"></div>
            </div>

            <div class="col-12 form-row">
                <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.address1.id_for_label }}">
                    {{ form.address1.label }}
                </label>
                <div class="col-sm-8 col-md-2 col-lg-1">
                    {{ form.zipcode|add_class:"form-control mb-1"|attr:"placeholder:우편번호"|attr:"readonly"|attr:"onclick=sample2_execDaumPostcode('id_')" }}
                    {{ form.zipcode.errors }}
                </div>
                <div class="d-none d-sm-block col-sm-4 d-md-none"></div>
                <div class="col-sm-8 col-md-2 col-lg-1">
                    <button type="button" class="btn btn-info mb-1" onclick="sample2_execDaumPostcode('id_')">우편번호
                    </button>
                </div>
                <div class="d-none d-sm-block col-sm-4 d-md-none"></div>
                <div class="col-sm-8 col-md-6 col-lg-4">
                    {{ form.address1|add_class:"form-control mb-1"|attr:"placeholder:주소"|attr:"onclick=sample2_execDaumPostcode('id_')" }}
                    {{ form.address1.errors }}
                </div>
                <div class="d-none d-sm-block col-sm-4 col-md-2 d-lg-none"></div>

                <div class="col-sm-8 col-md-5 col-lg-2">
                    {{ form.address2|add_class:"form-control mb-1"|attr:"placeholder:상세주소" }}
                    {{ form.address2.errors }}
                </div>
                <div class="d-none d-sm-block col-sm-4 d-md-none"></div>
                <div class="col-sm-8 col-md-5 col-lg-3">
                    {{ form.address3|add_class:"form-control mb-1"|attr:"placeholder:참고항목" }}
                    {{ form.address3.errors }}
                </div>
            </div>
        </div>

        <div class="col-12 form-row">
            <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.title.id_for_label }}">
                {{ form.title.label }}
            </label>
            <div class="col-sm-8 col-md-10 col-lg-11">
                {{ form.title|add_class:"form-control mb-1"|attr:"placeholder:고지서 제목" }}
                {{ form.title.errors }}
            </div>
            <div class="d-none d-md-block col-md-6 d-lg-none"></div>
        </div>

        <div class="col-12 form-row">
            <label class="col-sm-4 col-md-2 col-lg-1 m-auto" for="{{ form.content.id_for_label }}">
                {{ form.content.label }}
            </label>
            <div class="col-sm-8 col-md-10 col-lg-11">
                {{ form.content|add_class:"form-control mb-1"|attr:"placeholder:고지서 내용"|attr:"rows:4" }}
                {{ form.content.errors }}
            </div>
            <div class="d-none d-md-block col-md-6 d-lg-none"></div>
        </div>
    </div>

    <div class="row mt-2 bg-dragula border-top border-bottom">
        <div class="col-12 pt-2 pb-2 text-right">
            {% if request.user.is_superuser or request.user.staffauth.notice > '1' %}
                <button type="submit" class="btn btn-{% if bill_issue %}success{% else %}primary{% endif %}">
                    {% if bill_issue %}업데이트{% else %}등록하기{% endif %}
                </button>
            {% else %}
                <button type="button" class="btn btn-outline-secondary" onclick="alert('수납 고지서 발행 권한이 없습니다. 관리자에게 문의하여 주십시요.')">조회권한 사용자</button>
            {% endif %}
        </div>
    </div>
</form>
